module.exports   B
last analyzed

Complexity

Conditions 6
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 6
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 22
rs 8.6737
ccs 10
cts 10
cp 1
crap 6
1
/*!
2
 * inherits.js | v0.2.0 | Easily inherit prototypes.
3
 * Copyright (c) 2017 Eric Zieger (MIT license)
4
 * https://github.com/theZieger/inherits.js/blob/master/LICENSE
5
 *
6
 * inherit the prototype of the SuperConstructor
7
 *
8
 * Warning: Changing the prototype of an object is, by the nature of how
9
 * modern JavaScript engines optimize property accesses, a very slow
10
 * operation, in every browser and JavaScript engine. So instead of using
11
 * Object.setPrototypeOf or messing with __proto__, we create a new object
12
 * with the desired prototype using Object.create().
13
 *
14
 * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
15
 *
16
 * @param {Object} Constructor
17
 * @param {Object} SuperConstructor
18
 *
19
 * @throws {TypeError} if arguments are `null`, `undefined`, or
20
 *                     `SuperConstructor` has no prototype
21
 *
22
 * @returns {Void}
23
 */
24 1
module.exports = function(Constructor, SuperConstructor) {
25 6
  if (Constructor === undefined || Constructor === null) {
26 2
    throw new TypeError('Constructor argument is undefined or null');
27
  }
28
29 4
  if (SuperConstructor === undefined || SuperConstructor === null) {
30 2
    throw new TypeError('SuperConstructor argument is undefined or null');
31
  }
32
33 2
  if (SuperConstructor.prototype === undefined) {
34 1
    throw new TypeError('SuperConstructor.prototype is undefined');
35
  }
36
37
  /**
38
   * for convenience, `SuperConstructor` will be accessible through the
39
   * `Constructor.super_` property
40
   */
41 1
  Constructor.super_ = SuperConstructor;
42
43 1
  Constructor.prototype = Object.create(SuperConstructor.prototype);
44 1
  Constructor.prototype.constructor = Constructor;
45
};
46